﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using JustinAngel.MetroBlog.Common.IoC;
using JustinAngel.MetroBlog.Models;
using JustinAngel.MetroBlog.Services.CategoryService;
using Microsoft.Practices.Unity;
using JustinAngel.MetroBlog.Common.Helpers;

namespace JustinAngel.MetroBlog.Controllers
{
    public class CategoryController : Controller
    {
        public CategoryController()
        {
            IoC.BuildUp(this);
        }

        [Dependency]
        public ICategoryService CategoryService { get; set; }

        [OutputCache(Duration = 60 * 15, VaryByParam = "none")]
        public ActionResult Show(string link)
        {
            var category = CategoryService.GetByLink(link);

            ViewData["SidebarModel"] = new SidebarModel(category.Link, category.Name + " articles");
            this.SetWebsiteRoot();

            return View("Category", category);
        }

    }
}
